using Microsoft.EntityFrameworkCore;
using ApiTest.Api.Entity;
namespace ApiTest.Api.Db
{
    public class ApiTestDb : DbContext
    {

        public ApiTestDb(DbContextOptions<ApiTestDb> db) : base(db)
        {

        }
        //用户表
        public DbSet<Users> Users { get; set; }
        //商品表
        public DbSet<Spu> Spu { get; set; }
        //Sku表
        public DbSet<Sku> Sku {get;set;}
        //店铺表
        public DbSet<Shop> Shop {get;set;}
        //分类表
        public DbSet<Classify> Classify {get;set;}
        //细分类表
        public DbSet<Subclassify> Subclassify {get;set;}
        //商品规格表
        public DbSet<Spuspecification> Spuspecification {get;set;}
        //商品规格值表
        public DbSet<Spuspecificationvalue> Spuspecificationvalue {get;set;}
        //规格表
        public DbSet<Specification> Specification {get;set;}
        //规格值表
        public DbSet<Specificationvalue> Specificationvalue { get; set; }
        //图片表
        public DbSet<UploadFileInfo> UploadFileInfo { get; set; }
        //商品图片表
        public DbSet<SpuImage> SpuImage { get; set; }
        //评论表
        public DbSet<Comment> Comment { get; set; }

        public DbSet<AuditInfo> AuditInfo { get; set; }
        //订单表
        public DbSet<Order> Order { get; set; }
        //购物车表
        public DbSet<ShopingCar> ShopingCar{get;set;}

        protected override void OnConfiguring(DbContextOptionsBuilder options)
        {
            options.UseSqlServer(@"server=DESKTOP-QVBQ9KL\SQLEXPRESS;database=ApiTest;uid=sa;pwd=123456;");
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
         {
                //User种子数据
                modelBuilder.Entity<Users>().HasData(
                new Users 
                { 
                    Id=1,
                    Username="admin",
                    Password="113",
                    IsActived=true,
                    IsDeleted=false,
                    CreatedTime = System.DateTime.Now,
                    UpdatedTime = System.DateTime.Now,
                    Remarks = "管理员",
                    Phone="",
                    Address="",
                    Consignee=""

                    
                }
                );
         }
    }
}